package com.bw.a1908.presenter;

import android.util.Size;

import com.blankj.utilcode.util.SizeUtils;
import com.bw.a1908.bean.VideoBean;
import com.bw.a1908.contract.VideoContract;
import com.bw.a1908.core.http.call.CallObserver;
import com.bw.a1908.core.mvp.BasePresenter;
import com.bw.a1908.model.VideoModel;

import java.util.List;

import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;

public class VideoPresenter extends BasePresenter<VideoContract.Model, VideoContract.View> {

    public VideoPresenter(VideoContract.View mView) {
        super(new VideoModel(), mView);
    }

    public void list() {
        mModel.requestVideo(1, new CallObserver<List<VideoBean>>() {

            @Override
            public void onSubscribe(@NonNull Disposable d) {
                addDisposable(d);
            }

            @Override
            public void success(List<VideoBean> bean) {
                for (VideoBean videoBean : bean) {
                    videoBean.height = (int) (SizeUtils.dp2px(200)+SizeUtils.dp2px(100)*Math.random());
                }
                mView.initAdapter(bean);
            }

            @Override
            public void fail(String msg) {

            }
        });
    }

}
